package priv.pront.code.lanqiao.competition.course.date0329;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 筛选号码 {
    static int n,index = 0;
    static List<Integer> list = new ArrayList<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            list.add(i);
        }
        while (list.size() != 1) {
            index += 2;
            while (index >= list.size()) {
                index = index - list.size();
            }
            list.remove(index);
        }
        System.out.println(list.get(0));

    }
}
